package com.mes.cloud.dao;

import com.mes.cloud.api.dto.request.employee.PositionPageListRequest;
import com.mes.cloud.api.dto.request.employee.SysEmployeePositionBusinessRequest;
import com.mes.cloud.api.dto.request.position.RelationEmployeeRequest;
import com.mes.cloud.api.dto.request.position.SysPositionEmployeePageRequest;
import com.mes.cloud.entity.SysEmployeePosition;
import com.mes.cloud.entity.param.BreakEmployeePositionTypeParam;
import com.mes.cloud.entity.vo.employee.PositionVo;
import com.mes.cloud.entity.vo.employee.SysEmployeePositionBusinessVo;
import com.mes.cloud.entity.vo.position.AuthorisationTypeVo;
import com.mes.cloud.entity.vo.position.CompartmentByEmployeeVo;
import com.mes.cloud.entity.vo.position.SysEmployeePositionPageVo;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.ids.SelectByIdsMapper;

import java.util.List;

/**
 * 用户岗位
 *
 * @author xy
 * @version 2019-08-02 14:28:28
 * @email yuan.xue3@pactera.com
 */
public interface SysEmployeePositionDao extends SelectByIdsMapper<SysEmployeePosition>, Mapper<SysEmployeePosition> {

    /**
     * 批量插入
     *
     * @param sysEmployeePositionList
     * @return int
     */
    int batchInsert(List<SysEmployeePosition> sysEmployeePositionList);

    /**
     * 批量删除
     *
     * @param ids
     * @return int
     */
    int batchDelete(@Param("ids") List<String> ids);

    /**
     * 岗位列表查询
     *
     * @param positionPageListRequest
     * @return List<PositionVo>
     */
    List<PositionVo> positionPageList(PositionPageListRequest positionPageListRequest);

    /**
     * 更新主要岗位
     *
     * @param employeeId
     * @return int
     */
    int updatePositionMainFlag(@Param("employeeId") String employeeId);

    /**
     * <岗位员工列表>
     *
     * @param sysPositionEmployeePageRequest
     * @return List<SysEmployeePositionPageVo>
     * @author xy
     * @date 2019/8/7 15:08
     */
    List<SysEmployeePositionPageVo> positionEmployeePageList(SysPositionEmployeePageRequest sysPositionEmployeePageRequest);

    /**
     * <批量更新>
     *
     * @param relationEmployeeRequest
     * @return int
     * @author xy
     * @date 2019/8/8 16:37
     */
    int positionRemoveRelationEmployee(RelationEmployeeRequest relationEmployeeRequest);

    /**
     * <根据岗位更新>
     *
     * @param relationEmployeeRequest
     * @return int
     * @author xy
     * @date 2019/8/9 16:05
     */
    int updateByPositionId(RelationEmployeeRequest relationEmployeeRequest);

    int updateByPositionIdAndEmployeeId(SysEmployeePosition sysEmployeePosition);

    /**
     * <查询数量>
     *
     * @param positionId
     * @return int
     * @author xy
     * @date 2019/8/10 12:57
     */
    int selectRelationCount(String positionId);

    /**
     * <员工岗位>
     * @author xy
     * @date   2019/9/9 14:17
     * @param  employeeId
     * @return List<SysEmployeePosition>
     */
    List<SysEmployeePosition> employeePositionList(String employeeId);

    /**
     * 根据岗位id查询员工信息
     * @param req
     * @return List<SysEmployeePositionBusinessVo>
     */
    List<SysEmployeePositionBusinessVo> getEmployeeByPositionId(SysEmployeePositionBusinessRequest req);

    /**
     * 查询当前岗所有上级岗位及岗位人员信息
     * @param req
     * @return List<SysEmployeePositionBusinessDto>
     */
    List<SysEmployeePositionBusinessVo> getAllParentEmployeeByPositionId(SysEmployeePositionBusinessRequest req);

    /**
     * 查询子级岗位员工信息
     * @param req
     * @return List<SysEmployeePositionBusinessVo>
     */
    List<SysEmployeePositionBusinessVo> getChildrenEmployeeByPositionId(SysEmployeePositionBusinessRequest req);

    /**
     * 删除员工与岗位的关联关系
     * @param updateby
     * @param updatebyNo
     * @param updateDateStr
     * @param emplid
     * @return
     */
    int deleteByEmployeeId(@Param("updateby") String updateby, @Param("updatebyNo") String updatebyNo, @Param("updateDateStr") String updateDateStr, @Param("emplid") String emplid);

    /**
     *  岗位下有多个员工 去一个 做为业务代表的主要员工
     * @param positionId
     * @return
     */
    CompartmentByEmployeeVo getCompartmentByEmployee(@Param("positionId") String positionId);

    List<PositionVo> queryPositionList(List<String> positionIds);


    /**
     * 更新员工的主要岗位
     * @param updatePositionMainFlagByPositionIdAndEmployeeId
     * @return
     */
    int  updatePositionMainFlagByPositionIdAndEmployeeId(SysEmployeePosition updatePositionMainFlagByPositionIdAndEmployeeId);

    List<String> queryPositionIdList(SysEmployeePosition selectParam);


    /**
     * 更新员工与岗位类型的关系
     * @param breakEmployeePositionTypeParam
     */
    int breakEmployeePositionType(BreakEmployeePositionTypeParam breakEmployeePositionTypeParam);

    /**
     * 查看员工某种岗位类型岗位的数量
     * @param employeeId
     * @param positionTypeId
     * @return
     */
    int setlectCountEmployeePositionType(String employeeId, String positionTypeId);

    AuthorisationTypeVo selectAuthorisationType(@Param("employeeId") String employeeId);

}
